home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#45 (Jun 89)
/
Supe SubCode
/
TrapDefs.a
< prev
next >
Wrap
Text File
|
1988-10-12
|
5KB
|
147 lines
PRINT OFF
INCLUDE 'Traps.a'
INCLUDE 'SysEqu.a'
PRINT ON,OBJ
CODEREFS FORCEJT
StackFrame RECORD {A6Link},DECR
DataSizePtr:ds.l 1
TrapSizePtr:ds.l 1
TrapAddrPtr:ds.l 1
retaddr: ds.l 1
A6Link: ds.l 1
stacksize: EQU *
ENDR
; =============================================================================
GetDrawTrapInfo PROC EXPORT
WITH StackFrame
link a6,#stacksize
move.l DataSizePtr(a6),a0
lea ParmEnd-ParmBeg,a1 ; compute size of parm's.
move.l a1,(a0) ; put it in a 'c' variable.
move.l TrapSizePtr(a6),a0
lea TrapEnd-TrapBeg,a1 ; compute size of trap code.
move.l a1,(a0) ; put it in a 'c' variable.
move.l TrapAddrPtr(a6),a0
lea TrapBeg,a1 ; put hook address ...
move.l a1,(a0) ; in a 'c' variable.
unlk a6
rts
ENDWITH
ParmBeg
SvRTS dc.l 0 ; place holder for compiling.
FcAdr dc.l 0 ; place holder for compiling.
TpAdr dc.l 0 ; place holder for compiling.
CLvl dc.l 0 ; place holder for compiling.
ParmEnd
; The following block of code actually gets copied down into
; the SysHeap due to trap table nearness requirements...
TrapBeg lea CLvl,a0
addq.w #1,(a0) ; keep track of nested hook calls.
cmpi.w #1,(a0) ; see how many calls deep we are.
bgt.s CallTrap ; just call trap if call level > 1.
CallHook lea SvRTS,a0 ; save address to get back too...
move.l (a7)+,(a0)
move.w (a7),d0 ; save 'len' pascal parm to 'DrawText'
clr.w (a7) ; 'clr.w' transforms 'offset' parm to MPW-C 'int'
ext.l d0 ; now transform 'len' parm to MPW-C 'int'.
move.l d0,-(a7) ; put 'len' parm back on stack.
move.l FcAdr,a0 ; get out address of our trap.
jsr (a0) ; call it with MPW-C stack parms.
add.l #12,a7 ; do a 'pascal' clean up.
lea CLvl,a0
subi.w #1,(a0) ; indicate exit of nested call.
move.l SvRTS,a0 ; setup jump to original caller.
jmp (a0) ; get out of here!!
CallTrap lea CLvl,a0
subi.w #1,(a0) ; indicate exit of nested call.
move.l TpAdr,a0 ; just call standard trap.
jmp (a0) ; this won't come back here.
TrapEnd
ENDPROC
; =============================================================================
GetResTrapInfo PROC EXPORT
WITH StackFrame
link a6,#stacksize
move.l DataSizePtr(a6),a0
lea ParmEnd-ParmBeg,a1 ; compute size of parm's.
move.l a1,(a0) ; put it in a 'c' variable.
move.l TrapSizePtr(a6),a0
lea TrapEnd-TrapBeg,a1 ; compute size of trap code.
move.l a1,(a0) ; put it in a 'c' variable.
move.l TrapAddrPtr(a6),a0
lea TrapBeg,a1 ; put hook address ...
move.l a1,(a0) ; in a 'c' variable.
unlk a6
rts
ENDWITH
ParmBeg
SvRTS dc.l 0 ; place holder for compiling.
FcAdr dc.l 0 ; place holder for compiling.
TpAdr dc.l 0 ; place holder for compiling.
CLvl dc.l 0 ; place holder for compiling.
ParmEnd
FontID EQU 4
; The following block of code actually gets copied down into
; the SysHeap due to trap table nearness requirements...
TrapBeg lea CLvl,a0
addi.w #1,(a0) ; keep track of nested hook calls.
cmpi.w #1,(a0) ; see how many calls deep we are.
bgt.s CallTrap ; just call trap if call level > 1.
CallHook: move.l 6(a7),d0 ; unload the resType from the stack.
cmpi.l #'FOND',d0 ; check it for type 'FOND'.
bne.s CallTrap ; do nothing if it isn't.
andi.w #$1FFF,FontID(a7) ; else - clear the special super/sub bits
; so FontMgr gets Font info of a known Font.
CallTrap: lea CLvl,a0
subi.w #1,(a0) ; indicate exit of nested call.
move.l TpAdr,a0 ; just call standard trap.
jmp (a0) ; this won't come back here.
TrapEnd
ENDPROC
; =============================================================================
UnChainHook PROC EXPORT
WITH StackFrame
link a6,#stacksize
move.l TrapSizePtr(a6),a0
lea TrapEnd-NormTrap,a1 ; compute size of trap code.
move.l a1,(a0) ; put it in a 'c' variable.
move.l TrapAddrPtr(a6),a0
lea NormTrap,a1 ; put hook address ...
move.l a1,(a0) ; put it in a 'c' variable.
unlk a6
rts
ENDWITH
SvRTS dc.l 0 ; place holder for compiling.
FcAdr dc.l 0 ; place holder for compiling.
TpAdr dc.l 0 ; place holder for compiling.
CLvl dc.l 0 ; place holder for compiling.
NormTrap move.l TpAdr,a0 ; just call standard trap.
jmp (a0) ; this won't come back here.
TrapEnd
ENDPROC
END